package com.scada.service.impl;

import java.util.HashMap;
import java.util.Map;

import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
import javax.jws.soap.SOAPBinding.Style;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.scada.dao.IMemberFamilyDao;
import com.scada.inf.MemberFamilyVisitor;
import com.scada.model.bean.MemberFamily;
import com.scada.model.result.ResponseBean;

@Service("memberFamilyVisitorService")
@WebService
@SOAPBinding(style = Style.RPC)
public class MemberFamilyVisitorImpl implements MemberFamilyVisitor{

	@Autowired
	private IMemberFamilyDao memberFamilyDao;
	
	@Override
	public ResponseBean deleteMemberFamilyById(String isShow, Long id) {
		
		ResponseBean responseBean = new ResponseBean();
		Map<String,Object> map = null;
		try{
			map = new HashMap<String,Object>(); 
			map.put("isShow", isShow);
			map.put("id", id);
			memberFamilyDao.deleteMemberFamilyById(map);
			responseBean.success();
		}catch(Exception e){
			responseBean.failed();
		}
		return responseBean;
	}

	@Override
	public ResponseBean insertMemberFamily(MemberFamily memberFamily) {
		
		ResponseBean responseBean = new ResponseBean();
		try{
			memberFamilyDao.insertMemberFamily(memberFamily);
			responseBean.success();
		}catch(Exception e){
			responseBean.failed();
		}
		return responseBean;
	}

	@Override
	public ResponseBean getMemberFamilyById(Long id) {
		
		ResponseBean responseBean = new ResponseBean();
		try{
			responseBean.addObject("result", memberFamilyDao.getMemberFamilyById(id));
			responseBean.success();
		}catch(Exception e){
			responseBean.failed();
		}
		return responseBean;
	}

	@Override
	public ResponseBean updateMemberFamily(MemberFamily memberFamily) {
		
		ResponseBean responseBean = new ResponseBean();
		try{
			memberFamilyDao.updateMemberFamily(memberFamily);
			responseBean.success();
		}catch(Exception e){
			responseBean.failed();
		}
		return responseBean;
	}

	@Override
	public ResponseBean getMemberFamilyByMemberId(String isShow, Long memberId) {
		
		ResponseBean responseBean = new ResponseBean();
		try{
			Map<String,Object> map = new HashMap<String,Object>(); 
			map.put("isShow", isShow);
			map.put("memberId", memberId);
			responseBean.addObject("result", memberFamilyDao.getMemberFamilyByMemberId(map));
			responseBean.success();
		}catch(Exception e){
			responseBean.failed();
		}
		return responseBean;
	}

}
